

package com.hexinfo.dmpro.script.config.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.common.annotation.AnonymousAccess;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.script.config.model.ConfigPathGit;
import com.hexinfo.dmpro.script.config.service.ConfigPathGitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * git路径配置表
 *
 * @author zl
 * @date 2024-02-26 14:24:35
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/configpathgit")
@Api(value = "configpathgit", tags = "git路径配置表管理")
public class ConfigPathGitController {

    private final ConfigPathGitService configPathGitService;

    /**
     * 分页查询
     *
     * @param page          分页对象
     * @param configPathGit git路径配置表
     *                      WrapperEnhancer.like(configPathGit); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    @AnonymousAccess
    public ResponseEntity<Object> getConfigPathGitPage(Page page, ConfigPathGit configPathGit) {
        return ResponseEntity.ok(configPathGitService.queryList(page, configPathGit));
    }


    //不分页查询
    @GetMapping("/list")
    @AnonymousAccess
    public ResponseEntity<Object> getConfigPathGitNoPage(ConfigPathGit configPathGit) {
        return ResponseEntity.ok(configPathGitService.queryListNoPage(configPathGit));
    }


    /**
     * 通过id查询git路径配置表
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public ResponseEntity<Object> getById(@PathVariable("id") String id) {
        return ResponseEntity.ok(configPathGitService.getById(id));
    }

    /**
     * 新增git路径配置表
     *
     * @param configPathGit git路径配置表
     * @return R
     */
    @ApiOperation(value = "新增git路径配置表", notes = "新增git路径配置表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody ConfigPathGit configPathGit) {
        return ResponseEntity.ok(configPathGitService.save(configPathGit));
    }

    /**
     * 修改git路径配置表
     *
     * @param configPathGit git路径配置表
     * @return R
     */
    @ApiOperation(value = "修改git路径配置表", notes = "修改git路径配置表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody ConfigPathGit configPathGit) {
        return ResponseEntity.ok(configPathGitService.updateById(configPathGit));
    }

    /**
     * 通过id删除git路径配置表
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除git路径配置表", notes = "通过id删除git路径配置表")
    @DeleteMapping("/{id}")
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(configPathGitService.removeById(id));
    }


}
